
import { BrowserRouter, Route, Routes } from "react-router-dom";
import { RouterConfig, RouterType } from "./router";

/**渲染路由，方法组件*/
function AppRouter(props: { data: RouterType[] }) {
    const data = props.data;
    return (
        <BrowserRouter /*basename="index"*/ >
            <Routes /*只匹配第一个避免重复匹配*/ > 
                { data.map((item: RouterType) => <Route key={item.id} path={item.path} element={<item.element />} />) }
            </Routes>
        </BrowserRouter>
    )
}

export default function App() {
    return <AppRouter data={RouterConfig} />;
}
